<?php

    // any methods you put here will be globally available to your controllers and templates

	function get_meta_keywords($w=null)
	{
		if(!is_null($w)) return htmlentities($w);
	}

	function get_meta_description($w=null)
	{
		if(!is_null($w)) return htmlentities($w);
	}

	function get_page_title($w=null)
	{
		if(!is_null($w)) {
			return htmlentities($w);
		} else {
			return 'Welcome to pixel app';
		}
	}
	
	function admin_subnav()
	{
	    $subnav = array();
		if (has_access_to('Admin::Modify Users')) { 		
			$subnav['Users'] = array('controller'=>'admin/users');
		}
		if (has_access_to('Admin::Modify Roles')) { 		
			$subnav['Roles'] = array('controller'=>'admin/roles');
		}
		if (has_access_to('Admin::Modify Permissions')) { 		
			$subnav['Access Permissions'] = array('controller'=>'admin/access');
		}
		if (has_access_to('Admin::Modify Config')) { 		
			$subnav['Site Config'] = array('controller'=>'admin/config');
		}
		if (has_access_to('Admin::Modify Firms')) { 		
			$subnav['View Firms'] = array('controller'=>'admin/firms');
		}
		return $subnav;
	}


	// this function is best used when you want to display news
	// in another location (other then the news controller)
	/*
	$news = get_news();
	if(!empty($news)) {
		foreach($news as $n) {
			printf('<li><b>%s</b><br>%s</li>',
			format_date_string($n['publish_date']),
			$n['title']);
		}
	}
	*/
	function get_news()
	{
		use_model('news');
		$news = new News();
		return $news->find_rows(array(
			'fields'=>array('index_name','title','publish_date','content'),
			'limit'=>3,
			'order'=>'publish_date DESC'));
	}
?>